Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define CloudWatch Alarm Payload structure #296

Merged
merged 11 commits into from
Jul 21, 2020
Merged

Conversation

paritosh16
Copy link

Issue

Tries to solve an issue similar to #51 for CloudWatch Alarm Payload in a SNSEvent. If this this merged, can do another PR to resolve #51

Description of changes

TL;DR

Added struct for CloudWatch Alarm payload.

Details

  • CloudWatch Alarm information lands up in SNSEntity.
  • This payload is a valid json string in the SNSEntity.Message containing information about the alarm that changed state and published to SNS topic triggering the lambda function.
  • CloudWatch Alarm payload can contain either:
    • Metrics: A list inside the Trigger section of the payload.
      • Metrics contains the list of metrics alarm is based off.
    • Metric: Details of the single metric that the alarm is based off.
  • A sample event containing Metrics can be found here.
  • A sample event containing single Metric information can be found here.

Structs Details

  • The CloudWatchAlarmSnsPayload struct refers to first level in the JSON containing information.
  • The CloudWatchAlarmTrigger struct refers to the trigger information.
  • The CloudWatchMetricDataQuery struct refers to the list of Metrics inside Trigger.
  • The CloudWatchMetricStat struct refers to the MetricStat key inside the Metric Data Query.
  • The CloudWatchMetric struct refers to the Metric information inside MetricStat.
  • The CloudWatchDimension struct refers to Dimensions of the metric inside CloudWatchMetric.

Why so many structs?

  • All the structs defined except CloudWatchAlarmSnsPayload are already defined in the CloudWatch module in the AWS GO SDK.
  • However, the structs in the CloudWatch module don't have any json definitions and hence to be in sync with how SNS related structs are defined, these have to defined again.
  • Finally, all structs can be defined as nested ones in a single CloudWatchAlarmSnsPaylaod but for better readability nested structs are defined separately.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2020

Codecov Report

Merging #296 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #296   +/-   ##
=======================================
  Coverage   74.06%   74.06%           
=======================================
  Files          18       18           
  Lines         833      833           
=======================================
  Hits          617      617           
  Misses        152      152           
  Partials       64       64           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b4291a...065232b. Read the comment docs.

events/sns.go Outdated Show resolved Hide resolved
events/sns.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@paritosh16 paritosh16 requested a review from bmoffatt June 9, 2020 20:54
@bmoffatt
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there a cloudwatch events example.
4 participants